Repository navigation
fix(mcp): skip unreadable regions before splitting scans - #128
Open
StupidDev1337 wants to merge 1 commit into
Open
StupidDev1337 wants to merge 1 commit into
StupidDev1337 wants to merge 1 commit into
Conversation
On Windows the region snapshot spans the whole address space, MEM_FREE and MEM_RESERVE ranges included (~128 TiB on a 64-bit target). _run_batched_scan cut all of it into scan_batch_bytes pieces, about two million batches at the 64 MiB default, so scan_value and scan_pattern spent their whole budget before reaching the heap. Leave unreadable regions out before split_regions/batch_regions in _run_batched_scan and find_pointer_paths. Every backend's scan already drops them through default_scan_filter, and scan_pointer_paths keeps only readable regions, so results do not change. Fixes JeanExtreme002#127 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why is this PR necessary, what does it do?
Fixes #127. On 64-bit Windows targets,
scan_valueandscan_patternran out of the 30 s budget before they reached the heap.MEM_FREEandMEM_RESERVEranges included._run_batched_scancut all of that intoscan_batch_bytespieces. At the 64 MiB default that is about 2 million batches for ~128 TiB.This PR leaves unreadable regions out before
split_regions/batch_regions:_run_batched_scanfilters the snapshot to readable regions first. Unreadable regions can never hold a match, and every backend's scan already drops them throughdefault_scan_filter, so the results do not change.find_pointer_pathsapplies the same filter before cutting regions for the pointer map.scan_pointer_pathsalready keeps only readable regions itself, so the map does not change. It just no longer builds millions of pieces first.list_memory_regionsand the session's region snapshot are untouched.How it was tested
tests/mcp_server/test_toolset.py(TestHugeRegionsAreScannedInPieces) use a fake target with a 1 MiB unreadable region below its two readable ones.flake8 PyMemoryEditor testsandmypy PyMemoryEditorreport no issues.pytest tests) on Windows 11 x64, Python 3.13.14, with thespeedextra: 1832 passed, 28 skipped, 1 failed.tests/process/test_foreign_process.py, and it fails the same way on unmodifiedmain.sys.executableis the venv launcher, which starts the real interpreter as a child, so the test opens the launcher's pid (WinError 299).--scan-batch-bytes:scan_valuereturns the counter withcount: 1,partial: false,elapsed_seconds: 0.002;count: 0,partial: true,elapsed_seconds: 30.122.Checklist (complete all items):
References:
Fixes #127
Notes:
MemoryRegion.is_readable, so it is platform-independent. I could only run it on Windows; CI will cover Linux and macOS.🤖 Generated with Claude Code